import React from 'react'

class Header extends React.Component {
  handleAddTodo = event => {
    const { value } = event.target
    if (event.keyCode === 13 && value.trim()) {
      this.props.addTodoItem(value)
      event.target.value = ''
    }
  }

  render() {
    return (
      <div className="mb-1">
        <input
          className="form-control"
          type="text"
          placeholder="输入你的代办事项，输入回车确定"
          onKeyUp={this.handleAddTodo}
        />
      </div>
    )
  }
}

export default Header
